//
//  SN_QuestionBgAlertView.m
//  Shiyun_Newspaper
//
//  Created by zz on 17/6/21.
//  Copyright © 2017年 ShiYun. All rights reserved.
//

#import "SN_QuestionBgAlertView.h"

#import "SN_AlertModel.h"

@implementation SN_QuestionBgAlertView


+ (instancetype)alertWithTitle:(NSString *)title gradeId:(NSString *)gradeId editionId:(NSString *)editionId courseId:(NSString *)courseId parentView:(UIView *)parentView {
    
    NSAssert(parentView != nil, @"parentView can not be nil");
    SN_QuestionBgAlertView *view = [[self alloc] initWithFrame:parentView.bounds];
    
    view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    
    [parentView addSubview:view];
    
    SN_QuestionAlert *alert = [[SN_QuestionAlert alloc] initWithSuperView:view andTitle:title];
    
    alert.delegate = (id<SN_QuestionAlertDelegate>)parentView.nextResponder;
    
    
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setObject:@"api_szb_yearphaselist" forKey:@"method"];
    [dict setObject:editionId forKey:@"editiontype"];
    [dict setObject:gradeId forKey:@"gradersid"];
    [dict setObject:courseId forKey:@"courseid"];
    
    
    [Utils getWithparameters:dict showHUD:YES success:^(NSInteger recode, id jsonObject) {
        
        NSArray *arr = [jsonObject objectForKey:@"re_data"];
        
        NSMutableArray *dataArr = [SN_AlertModel mj_objectArrayWithKeyValuesArray:arr];
        
        alert.dataArr = dataArr;
        
    } failure:^(NSInteger recode, NSError *error) {
        
        
    }];
    
    return view;
}

@end
